package org.example.shejimoshi.yuanze.yilai;

/**
 * set方式进行依赖注入
 */
public class PurchaseBook2 {
    private Book1 book;

    public void setBook(Book1 book){
        this.book = book;
    }

    public void getBook(){
        book.getBook();
    }

    public static void main(String[] args) {
        PurchaseBook2 purchaseBook = new PurchaseBook2();
        purchaseBook.setBook(new JavaBook1());
        purchaseBook.getBook();
    }
}

